<?php echo $this->fetch('header.html'); ?>
<style>
.kdorder_add {background:#e9e9e9;}
.kdorder_add th {font-size:13px; color:#333; background:#f0f7ff; width:150px; font-weight:normal;text-align:right; padding-right:5px;}
.kdorder_add th em {font-style:normal; color:#F00; margin-right:8px}
.kdorder_add td{padding:5px; background:#FFF;}
.kdorder_add td span{color:#F00; margin-left:5px;} 
.kdorder_add .houseName{color: #f00;font-size:45px;font-family:"Microsoft YaHei"; font-weight:normal}
.kdorder_add .select_class {border: 1px #ccc solid;height: 30px;border-radius:2px;width:390px}
.inputBorder1{background: #333;width: 360px;color: #fff;padding: 15px;font-size: 30px;}
.inputBorder{border: 1px #ccc solid;height: 20px;line-height: 20px;padding:6px 5px; width:380px}
.botton_submit {border:0;background:#ed5736;height:31px;width:100px;text-align:center;line-height:31px;font-family:"Microsoft YaHei";font-size:14px;color:#fff;cursor:pointer;border-radius:4px; margin-right:10px}
.botton_submit.hui {background:#999; color:#CCC}
</style>
<div id="rightTop">
  <ul class="subnav">
    <li><a class="btn1" href="index.php?app=kd_yubao">预报记录</a></li>
    <li><a class="btn1" href="index.php?app=kd_yubao&act=add">到货预报</a></li>
    <li><a class="btn0" href="index.php?app=kd_yubao&act=ruku">快速入库</a></li>
  </ul>
</div>
<form action="" method="post" id="form_box">
<table width="100%" cellspacing="1" class="kdorder_add">
  <tr><td colspan="2" style="padding:12px 8px;background:#ffffe5;line-height:18px; font-size:13px">操作提示：（1）操作顺序：第一步，先录入或扫描包裹单号，回车，第二步，如果没有预报，系统将提示您录入的是新的预报信息，输入或通过电子秤录入重量后回车，即可以入库。第三步，如果是没预报的包裹，则录入重量后入库，第四步，系统将重置当前页面，并提示你已经准备好接受新的包裹录入。
（2）当您选择一个仓库后，系统默认后续将一直保持选中该仓库，除非您手工更改为其它仓库（中转包裹选项也是如此）；请使用带有回车功能的条码枪进行操作，配合能自动录入重量的电子秤可以最大程度的提高工作效率。</td></tr>
  <tr>
    <th><em>*</em>到货仓库：</th>
    <td>
    <select name="cangku" id="cangku" class="select_class">
    <?php $_from = $this->_var['category']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'list');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['list']):
?>
    <option value="<?php echo $this->_var['list']['cate_name']; ?>" <?php if ($this->_var['info']['cangku'] == $this->_var['list']['cate_name']): ?>selected="selected"<?php endif; ?>><?php echo $this->_var['list']['cate_name']; ?></option>
    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    </select>        
    </td>
  </tr>
  <tr>
    <th>当前仓库：</th>
    <td style="padding:10px 8px;"><strong id="houseName" class="houseName"></strong></td>
  </tr>
  <tr>
    <th><em>*</em>包裹运单号：</th>
    <td><input type="text" name="yundanhao" id="yundanhao" class="inputBorder1" onkeypress="return doClick(event);"/><span id="yundanhaotip">回车</span></td>
  </tr>
  <tr>
    <th><em>*</em>重量(LB)：</th>
    <td><input type="input" name="GoodsWeight" id="GoodsWeight" class="inputBorder1" onKeyUp="clearNoNum(this)" onkeypress="return doClick(event);"/><span id="weighttip">回车</span></td>
  </tr>
  <tr>
    <th>&nbsp;</th>
    <td>
    <input type="submit" name="addbtn" class="botton_submit hui" value="更新入库" onclick="return Check_form();" disabled="disabled"/>
    <input type="reset" class="botton_submit" value="返回上一页" style="background:#999" onclick="javascript:history.back();"/>
    <input type="hidden" name="act"  value="ruku"/>
    <input type="hidden" name="yubao_id"  value="0"/>
    </td>
  </tr>
  <tr>
    <td colspan="2" height="25">&nbsp;</td>
    </tr>  
  <tr>
    <th>库存位置：</th>
    <td><input type="input" class="inputBorder" name="CangkuWeizhi" id="CangkuWeizhi" value="<?php echo $this->_var['info']['CangkuWeizhi']; ?>" placeholder="请输入库存位置" style="border-color:#CCC"/></td>
  </tr>
  <tr>
    <th valign="top" style="padding-top:8px">管理员备注：</th>
    <td><label><input name="wentijian" type="checkbox" value="1" /> 问题件</label><br />
      <input name="admin_genzong" type="text" class="inputBorder" id="admin_genzong" style="border-color:#CCC" value="" placeholder="请输入管理员备注" />
      <textarea name="admin_genzong_old" id="admin_genzong_old" style="display:none"></textarea>
      </td>
  </tr>    
</table>

</form>
<script type="text/javascript">
$(document).ready(function () {
    $("#yundanhao").focus();
	showHouseName();
	$("#cangku").change(function () {
		$.setCookie("hid", $(this).val());
		showHouseName();
	});
	$("#yundanhao").keyup(function () {
		if (event.keyCode == 13) {
			checkShippingOrder();
		}
	});
	$("#GoodsWeight").keyup(function () {
		if (event.keyCode == 13) {
			if ($(this).val()) {
				if(typeof($("input[name='addbtn']").attr("disabled"))=="undefined")$("input[name='addbtn']").click();
			} else {
				$(this).focus().select();
			}
		}
	});
});
function showHouseName() {
  if ($.getCookie("hid") != 0 ) {
	  $("#cangku").val($.getCookie("hid"));
  } else {
	  $.setCookie("hid", $("#cangku").val());
  }
  $("#houseName").text($("#cangku option:selected").text());
}
//扫描入库
function checkShippingOrder() {
  var yundanhao = $("#yundanhao").val();
  if (yundanhao != '') {
	$.get("index.php?app=kd_yubao&act=ruku_check", {yundanhao: yundanhao, r: Math.random()},function (data) {
	var info = jQuery.parseJSON(data);
	switch (info) {
		case 'NO':
			{
				$("input[name='yubao_id']").val("0"); //新增
				$("#yundanhaotip").html("新增运单");
				$("#GoodsWeight").val("").focus();
			} break; //这里要实现弹窗填写新运单
		default:
			{
				var tmp = "用户ID:" + info.user_name + "，下单时间：" + info.addtime;
				$("#GoodsWeight").val(parseFloat(info.GoodsWeight)).focus().select();
				$("#CangkuWeizhi").val(info.CangkuWeizhi);
				$("input[name='yubao_id']").val(info.yubao_id); //更新
				$("#admin_genzong_old").val(info.admin_genzong);
				$("input[name='addbtn']").removeClass("hui");
				switch (info.status) {
					case '0': {
						tmp += "，状态：未入库。";
						$("input[name='addbtn']").attr("disabled", false).removeClass("hui");
					  } break;					
					case '1':{
						tmp += "，状态：已入库，库存位置：" + info.CangkuWeizhi + "。";
						$("input[name='addbtn']").attr("disabled", true).addClass("hui");
					  } break;
					case '2': {
						tmp += "，状态：已发出。";
						$("input[name='addbtn']").attr("disabled", true).addClass("hui");
					  } break;
					case '3': {
						tmp += "，状态：转仓件。";
						$("input[name='addbtn']").attr("disabled", true).addClass("hui");
					  } break;
					case '4': {
						tmp += "，状态：问题件。";
						$("input[name='addbtn']").attr("disabled", true).addClass("hui");
					  } break;
					case '5':{
						tmp += "，状态：待认领。";
						$("input[name='addbtn']").attr("disabled", true).addClass("hui");
					  } break;
					case '6': {
						tmp += "，状态：已取消。";
						$("input[name='addbtn']").attr("disabled", true).addClass("hui");
					  } break;
				}
				$("#yundanhaotip").html(tmp);
			} break;
		}
	});
  }
}

//sumbit form
function Check_form(){
  if ($("#cangku").val() == "0") {alert("请选择到货仓库");$("#cangku").focus(); return false;}
  if ($("#yundanhao").val() == "") {alert("请输入包裹运单号");$("#yundanhao").focus(); return false;}
  if ($("#GoodsWeight").val() == "") {alert("请输入物品重量");$("#GoodsWeight").focus(); return false;}
  $("#form_box").submit();
}
//按enter键,阻止提交订单
function doClick(event){
  var key;
  if (window.event){
	  key = window.event.keyCode; //IE  
  }else{
	  key = event.which; //firefox  
  }
  if (key == 13) {
	  try{
		  if (window.event) {//ie  
			  window.event.keyCode = 0;
			  window.event.returnValue = false;
		  }else {//firefox  
			  return false;
		  }
	  }catch(ex) {}
  }
}
</script>
<?php echo $this->fetch('footer.html'); ?>